//
//  DDView.m
//  DDSDK
//
//  Created by tucici on 2019/5/28.
//  Copyright © 2019 tucici. All rights reserved.
//

#import "DDView.h"
NSString * const CCNoticeNameDDViewBackBtnMethod = @"CCNoticeNameDDViewBackBtnMethod";
NSString * const CCNoticeNameDDViewCancelBtnMethod = @"CCNoticeNameDDViewCancelBtnMethod";
@interface DDView ()<DDNaviBarDelegate>
@end
@implementation DDView
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.layer.cornerRadius = GAP / 2.0;
        self.layer.masksToBounds = YES;
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (DDNaviBar *)bar
{
    if (!_bar)
    {
        _bar = [[DDNaviBar alloc] init];
        _bar.delegate = self;
        [self addSubview:_bar];
        _bar.c_left.c_equal(self);
        _bar.c_right.c_equal(self);
        _bar.c_height.c_equal(JTWNaviBarHeight);
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
            _bar.c_top.c_equal(self).with.coffset(GAP * 2);
        else
            _bar.c_top.c_equal(self);
        
        //        if ([UIApplication sharedApplication].statusBarHidden)
        //            _bar.c_top.c_equal(self);
        //        else
        //        {
        ////            [self setStatusBarBackgroundColor:self.bar.backgroundColor];
        //            _bar.c_top.c_equal(self).with.coffset(STATUS_HEIGHT);
        //        }
    }
    return _bar;
}

- (void)shouldBackToPreviousViewController
{
    [CCNotice post:CCNoticeNameDDViewBackBtnMethod obj:nil info:nil];
}
- (void)shouldCancelCurrentViewController
{
    [CCNotice post:CCNoticeNameDDViewCancelBtnMethod obj:nil info:nil];
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
